import sys
sys.path.insert(0,'../')
from RestAPI.amazon.S3 import  S3Request,S3session,Bucket,FileObject
from RestAPI.core.APIExceptions import *
import unittest
import setting

class testFileObj(unittest.TestCase):
    def setUp(self):
        self.session=S3session()
        self.session.setCredential(setting.AUTHID,setting.AUTHKEY)
        self.bucket=self.session.createBucketObj('feignwolf-test')
    def testGetUrl(self):
        fname='/test.py'
        print "test GET url for file %s from %s\n====================================================" % (fname,self.bucket.name)
        fobj=self.bucket.createFileObject(fname)
        print fobj.url('3 hours')
    def testUploadForm(self):
        fname='/test3.py'
        print "test get upload form for file %s from %s\n====================================================" % (fname, self.bucket.name)
        fobj=self.bucket.createFileObject(fname)
#        print fobj.uploadForm()
    def testUpload(self):
        fname='testAPIWrapper.py'
        print "test upload file %s into %s\n====================================================" % (fname,self.bucket.name)
        self.bucket.upload('test.py',fname)
    def testGet(self):
        fname="/FILES"
        print "test get file %s from %s\n====================================================" % (fname,self.bucket.name)
        #self.bucket.get(fname)
    def testInfo(self):
        fname="/FILES"
        print "test get file %s info from %s\n====================================================" % (fname,self.bucket.name)

if __name__ == '__main__':
    unittest.main()
